Home:ALL Converter>[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client in nextjs

[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client in nextjs

Ask Time:2022-03-22T23:48:58         Author:Anik Deb Nath

Json Formatter

error - Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at new NodeError (internal/errors.js:322:7) at ServerResponse.setHeader (_http_outgoing.js:561:11) at NodeNextResponse.setHeader (E:\EndGame\FoodMart-client-side\node_modules\next\dist\server\base-http.js:101:19) at DevServer.renderError (E:\EndGame\FoodMart-client-side\node_modules\next\dist\server\base-server.js:1094:17) at DevServer.renderError (E:\EndGame\FoodMart-client-side\node_modules\next\dist\server\next-server.js:414:22) at DevServer.run (E:\EndGame\FoodMart-client-side\node_modules\next\dist\server\dev\next-dev-server.js:451:35) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async DevServer.handleRequest (E:\EndGame\FoodMart-client-side\node_modules\next\dist\server\base-server.js:305:20) { code: 'ERR_HTTP_HEADERS_SENT' }enter image description here

i can not understand from where the erron come in terminal but live site is okk.

Author:Anik Deb Nath,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71575037/err-http-headers-sent-cannot-set-headers-after-they-are-sent-to-the-client-in
Aindriú :

In your Next.js application, check your pages/api/preview.js file. There is some code there that needs to be correct before the redirect will work\n export default function handler(req, res) {\n res.setPreviewData({}) \n res.redirect(req.query.redirect)\n}\n\nif you have something like the following your code won't work\n res.end('Preview mode enabled')\n",
2023-02-06T14:33:16
yy